<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE>
<html>
<script type="text/javascript">
			function onChangeTarget( option ) {
				var v_types = option.value;
				window.location.href="News.do?op=admin&pageCount=5&pageNum=1&typeid=" + v_types;
			}
</script>
<base href="<%=basePath%>">
  <head>
    <title>新闻管理</title>
  </head>
  <body>
  	<div style="float: left;"><h3>新闻管理</h3></div>
  	<div style="float: right;margin-top: 20px;">
  	选择新闻类型：
	  	<select name="types" onchange="onChangeTarget( this )">
	  		<option value="0">所有的新闻</option>
			<c:forEach var="types" items="${ requestScope.typeslist }">
				<option value="${types.typeid}" ${types.typeid==requestScope.typeid ? "selected" : "" }>${types.title}</option>
			</c:forEach>
		</select>
	</div>
  		<table class="table table-bordered table-hover table-condensed table-striped">
  			<thead>
  				<tr>
  					<th>
  					编号
  					</th>
  					<th>
  					标题
  					</th>
  					<th>
  					类型
  					</th>
  					<th>
  					点击次数
  					</th>
  					<th>
  					正文大小
  					</th>
  					<th>
  					发布时间
  					</th>
  					<th>
					推荐
  					</th>
  					<th>
  					关键字
  					</th>
  					<th>
  					发布者
  					</th>
  					<th>
  					操作
  					</th>
  				</tr>
  			</thead>
  			<tbody>
  				<c:forEach var="news" items="${ requestScope.newspage.data}" varStatus="st">
  				<tr>
  					<td>
  					${ news.newid }
  					</td>
  					<td>
  					${ news.title }
  					</td>
  					<td>
  					${ news.types.title}
  					</td>
  					<td>
  					${ news.click }
  					</td>
  					<td>
  					${ news.contentLenght }
  					</td>
  					<td>
  					${ news.releasetime }
  					</td>
  					<td>
  					${ news.recommended > 0 ? "是" : "否" }
  					</td>
  					<td>
  					${ news.keywords }
  					</td>
  					<td>
  					${ news.user.name }
  					</td>
  					<td>
  					<a href="News.do?op=delete&pageNum=1&pageCount=5&typeid=${ news.types.typeid}&newid=${ news.newid }" class="btn btn-success"> 删除</a>
  					<a href="News.do?op=update&pageNum=1&pageCount=5&typeid=${ news.types.typeid}&newid=${ news.newid }" class="btn btn-success"> 修改</a>
  					</td>
  				</tr>
  				</c:forEach>
  			</tbody>
  			<tbody>
  			 	<tr>
  			 		<td  colspan="10" align="right">
  			 			<c:if test="${ requestScope.newspage.pageNum ==1 }">首页</c:if>
  			 			<c:if test="${ requestScope.newspage.pageNum !=1 }">
  			 			<a href="News.do?op=admin&pageNum=${ requestScope.newspage.pageNum - 1 }&pageCount=5&typeid=0">上一页 </a>
  			 			</c:if>
  			 			<c:if test="${ requestScope.newspage.pageNum != requestScope.newspage.totalPages }">
  			 			<a href="News.do?op=admin&pageNum=${ requestScope.newspage.pageNum + 1 }&pageCount=5&typeid=0">下一页</a>
  			 			</c:if>
  			 			<c:if test="${ requestScope.newspage.pageNum == requestScope.newspage.totalPages }">尾页</c:if>
  			 		</td>
  			 	</tr>
  			</tbody>
  	 </table>
  </body>
</html>
